package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.TrendsUserDao;
import com.baichang.taoshunda.entity.TrendsUser;
import org.springframework.stereotype.Repository;

/**
 * Created by ${wushenglu} on 17/09/20.
 */
@Repository
public class TrendsUserDaoImpl extends BaseDaoImpl<TrendsUser> implements TrendsUserDao {
    @Override
    public int getTrendsUserIdByUserId(Integer userId) {
        String sql = "SELECT id  FROM t_trends_user WHERE user_id=?";
        return queryForInt(sql, userId);
    }

    /**
     * 根据商家编号查看互动用户编号
     *
     * @param bussId 用户编号
     * @return
     */
    @Override
    public int getTrendsUserIdByBussId(Integer bussId) {
        String sql = "SELECT id  FROM t_trends_user WHERE bus_id=?";
        return queryForInt(sql, bussId);
    }

    @Override
    public void updateTrendsStatus(String goodsId, int i) {
        String sql = "UPDATE `t_trends` SET `status`=? WHERE (`id`=?)";
        update(sql, i, goodsId);
    }

    @Override
    public void updateTrendsUserInfo(int trendsUserId, String name, String headPic) {
        String sql = "UPDATE `t_trends` SET `host_name`=?, `host_icon`=? WHERE (`user_id`=? )";
        update(sql, name, headPic, trendsUserId);
    }

    @Override
    public void updateTrendsReplayUserInfo(int trendsUserId, String name, String headPic) {
        String sql = "UPDATE `t_replay_comment` SET `replay_name`=?, `replay_icon`=? WHERE (`replay_user_id`=? )";
        update(sql, name, headPic, trendsUserId);
    }

    @Override
    public void updateTrendsCommentUserInfo(int trendsUserId, String name, String headPic) {
        String sql = "UPDATE `t_comment_trends` SET `comment_name`=?, `comment_icon`=? WHERE (`comment_user_id`=? )";
        update(sql, name, headPic, trendsUserId);
    }

    @Override
    public void updateTrendsReplayCommentUserInfo(int trendsUserId, String name) {
        String sql = "UPDATE `t_replay_comment` SET `comment_name`=?  WHERE (`comment_user_id`= ?)";
        update(sql, name, trendsUserId);
    }
}
